#include <func.h>

void* thread_func(void* p)
{
    while(1);
    return NULL;
}

int main()
{
    pthread_t th_id;
    int ret=pthread_create(&th_id,NULL,thread_func,NULL);
    THREAD_ERR_CHECK(ret,"pthread_create");
    printf("I am main thread\n");

    //子线程一直在运行，则无法cancel
    ret=pthread_cancel(th_id);
    THREAD_ERR_CHECK(ret,"pthread_cancel");

    //
    long thread_ret;
    ret=pthread_join(th_id,(void**)&thread_ret);
    THREAD_ERR_CHECK(ret,"pthread_join");
    printf("I am main thread %ld\n",thread_ret);
    return 0;
}